#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 111;

int t, n, a;
int main() {
    cin >> t;
    while(t--) {
        cin >> n;
        ll sum = 0;
        for (int i = 0; i < n ; i++) {
            cin >> a;
            sum += a;
        }

        if (sum % n == 0) cout << 0 << endl;
        else cout << 1 << endl;
    }
    return 0;
}